fix(SEC-004): stop shipping pytest in the production image - #122
Open
DoRmAmMu1997 wants to merge 1 commit into
Open
fix(SEC-004): stop shipping pytest in the production image#122DoRmAmMu1997 wants to merge 1 commit into
DoRmAmMu1997 wants to merge 1 commit into
Conversation
`requirements.txt` declared `pytest` as a runtime dependency under a "Test runner." heading. The Dockerfile installs `requirements.txt` and nothing else, so the test runner and its dependency tree were baked into the deployed image - on both the Render web service and the daily-scan cron. It was already declared in `requirements-dev.txt`, so this was a duplicate that bought nothing and only widened the production surface. Remove it, and add a policy guard so it cannot drift back. The guard checks the whole class of developer tooling (pytest, pytest-cov, ruff, bandit, pip-audit, mypy, pre-commit) and asserts each one is absent from requirements.txt AND still present in requirements-dev.txt - so the fix cannot be "solved" by deleting the dependency outright either. Verified by re-adding pytest to requirements.txt and watching the guard fail. The existing `constraints.txt` pin for pytest is untouched and still correct: constraints only pin versions for whatever is actually being installed, and CI installs both requirements files. Closes #121 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #121.
Problem
requirements.txtdeclaredpytestas a runtime dependency:Dockerfile:46-48installsrequirements.txt(withconstraints.txt) and nothing else, so the test runner and its dependency tree were baked into the deployed image — on both the Render web service and the daily-scan cron.It was already declared in
requirements-dev.txt:5, so this was a duplicate that bought nothing and only widened the production surface.Fix
Remove the block, and add
test_developer_tools_stay_out_of_the_runtime_requirementsso it cannot drift back.The guard deliberately covers the whole class of verification tooling —
pytest,pytest-cov,ruff,bandit,pip-audit,mypy,pre-commit— and makes two assertions per name:requirements.txt, andrequirements-dev.txt.The second half matters: without it, a future "fix" could satisfy the guard by deleting the dependency outright and quietly breaking CI's ability to run the gates.
Verification
pytesttorequirements.txtand confirmed the new guard fails, then removed it again.pytest -q --cov=... --cov-fail-under=89— 2035 passed, 1 skipped, 89.97%ruff check,compileall— cleangit diff origin/main HEAD -- constraints.txt pyproject.toml— empty (AGENTS.md §7)The
constraints.txtpin forpytestis untouched and still correct: constraints only pin versions for whatever is actually being installed, and CI installs both requirements files (pip install -r requirements.txt -r requirements-dev.txt -c constraints.txt).test_supply_chain_policy.py's existing assertion thatpytest==appears inconstraints.txtis unaffected and still passes.Noted, deliberately not fixed here
requirements-optional.txthas a related but separate problem — bareTA-Libandpandas_tawith no pins, absent fromconstraints.txt, sopip_audit -r constraints.txtnever audits them. Compounding it, no test exercises the accelerated branches they enable (backend/indicators.py:581,601,621,660,708,771,1016,1118) because CI never installs the packages. That deserves its own ticket, including the question of whether thepandas_tapath should simply be deleted.🤖 Generated with Claude Code